<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/css/work_today.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client_tracking.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client_tracking.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_student_read.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/model_resp.js"></script>
<script src="${staticServer}/inc/js/datepicker.js"></script>
<script src="${staticServer}/inc/js/htmlfilter.js"></script>
<script src="${staticServer}/inc/js/submitter.js"></script>
<script src="${staticServer}/inc/js/tips.js"></script>
<style type="text/css">
#statelist label {
	display: block;
	float: left;
	width: 120px;
}
</style>
<script>
$(function(){
	$("#sname1").val("${sname}");
	$("#sname2").val("${sname}");
	$("#state_s").val("${state_s}");
});

var getFollow = function(keyname,id){
	$("#traId").val(id);
	$.post("${contextPath}/index/get_client_follow.json", {
		"keyname":keyname
	}, function(ms) {
		var list = ms.list;
		var objHtml = "";
		$("#trackList"+id).val("");
		if(list!=null){
			var j=list.length+1;
			for(var i=0;i<list.length;i++){
				var state = "";
				if(list[i].state=="" || list[i].state==null){
					state = '<a class="stateitem caption">无变化</a>';
				}else{
					state = '<a class="stateitem">'+list[i].state+'</a>';
				}
				if(list[i].state2=="" || list[i].state2==null){
					state2 = '';
				}else{
					state2 = '<a class="stateitem">'+list[i].state2+'</a>';
				}
				if(list[i].state3=="" || list[i].state3==null){
					state3 = '';
				}else{
					state3 = '<a class="stateitem">'+list[i].state3+'</a>';
				}
				if(list[i].startTime != null){
					remind_date = list[i].startTime;
				}else{
					remind_date = "";
				}				
				objHtml += '<ul>'+
	            			'<li>'+
	            				'<p class="trackingtitle" style="display: block;">第 '+(--j)+' 次跟踪记录<em class="caption">（负责人：'+list[i].nickname+'　日期：'+list[i].createTime+'）</em><a class="btnHidden" onclick="btnShow(this)">点击展开</a></p>'+
	            				'<p class="trackingstate" style="display: none;"><b>客户状态</b><span>'+state+state2+state3+'</span></p>'+
	            				'<p style="display: none;"><b>备注情况</b></p>'+
	            				'<p style="display:none;" id="re" ><b>提醒时间</b><input readonly="readonly" style="margin-left:5px;" value="'+remind_date+'" class="DatePicker_Icon" type="text" name="remind" id="remind" size="15" value="" rel="DATE::Y-m-d" /></p>'+
	            				'<div class="content" style="display: none;">'+list[i].remark+'</div>'+
	            			'</li>'+
	            		'</ul>'
			}
			$("#trackList"+id).html('<a class="stress unit" onclick="remove_tracking()"> 点击隐藏跟踪记录 </a>'+objHtml);
			$("#__TRACKING_LIST"+id).show();
			
		}
		
	});
}

function btnShow(obj){
	 var b = $(obj).siblings('.caption').parent().parent().find('p:not(:first)').visible();
	 var s = $(obj).siblings('.caption').parent().parent().parent().children();
	 var h = $(obj).siblings('.caption').parent();
	 var remind = $(obj).siblings('.caption').parent().parent().find('#remind').val();
	 var sh = null;
	 if(remind!=""){
		 sh = $(obj).siblings('.caption').parent().parent().parent().children().children();
	 }else{
		 sh = $(obj).siblings('.caption').parent().parent().parent().children().children().not("#re");
	 }
	 
	 if(b == false){
			 sh.show();
			 s.show();
	 }else{
		 	sh.hide();
		 	h.show();
	 }
}

var remove_tracking = function(){
	var id = $("#traId").val();
	$("#__TRACKING_LIST"+id).hide();
}

function submit(){
	var sname1 = $("#sname1").val();
	var sname2 = $("#sname2").val();
	var state_s = $("#state").val();
	var sname = "";
	if(sname2!=null && sname2!=""){
		sname = sname2;
	}else{
		sname = sname1;
	}
	var startTime = $("#stardate").val();
	var endTime = $("#enddate").val();
	var invalid = $("#invalid").is(':checked');
	window.location.href="${contextPath}/network/shic_genz.htm?sname="+sname+"&startTime="+startTime+"&endTime="+endTime+"&invalid="+invalid+"&state_s="+state_s;
}

function query_stat(state_s){
	var sname1 = $("#sname1").val();
	var sname2 = $("#sname2").val();
	var sname = "";
	if(sname2!=null && sname2!=""){
		sname = sname2;
	}else{
		sname = sname1;
	}
	var startTime = $("#stardate").val();
	var endTime = $("#enddate").val();
	var invalid = $("#invalid").is(':checked');
	window.location.href="${contextPath}/network/shic_genz.htm?sname="+sname+"&startTime="+startTime+"&endTime="+endTime+"&invalid="+invalid+"&state_s="+state_s;
}
</script>
</head>

<body>
<input type="hidden" id="keyname" value="">
<input type="hidden" id="traId" value="">
	<div id="home_link">
		<ul>
			<li></li>
			<li>&gt;</li>
			<li>资源统计管理</li>
			<li>&gt;</li>
			<li class="current">市场资源跟踪</li>
		</ul>
	</div>
	<div id="container">
		<div id="title"></div>
		<table class="form_table">
			<tr>
				<td>
					<div style="overflow: hidden;">
						<label><b>查询条件：</b></label>
						<select id="sname1">
							<option value="">全部资源</option>
							<option value="公益讲座">公益讲座</option>
							<option value="市场部推广">市场部推广</option>
							<option value="传单派发">传单派发</option>
							<option value="市场部问卷">市场部问卷</option>
							<option value="公益微课">公益微课</option>
						</select>
						<input type="text" id="stardate" size="13" rel="DATE::Y-m-d" value="${startTime}" readonly="readonly" class="DatePicker_Icon">
						<input type="text" id="enddate" size="13" rel="DATE::Y-m-d" value="${endTime}" readonly="readonly" class="DatePicker_Icon">
						<label for="btnInvalid"><input type="checkbox" <#if invalid?? && invalid=="true">checked</#if> id="invalid" style="margin-top: 6px;" />过滤无效客户</label> 
						<input type="button" value=" 查 询 " onclick="submit()" />
					</div>
				</td>
			</tr>
		</table>
		<table>
			<tr class="fields">
				<th>客户</th>
				<th>登记人</th>
				<th>所在地</th>
				<th>渠道</th>
				<th><select style="margin-left:2px;" id="state" onchange="query_stat(this.value)">
						<option value="">客户状态</option>
			            <option value="已预约" <#if state_s == "已预约">selected</#if> >已预约</option>
			            <option value="已测评" <#if state_s == "已测评">selected</#if> >已测评</option>
			            <option value="已缴费" <#if state_s == "已缴费">selected</#if> >已缴费</option>
			            <option value="未出现" <#if state_s == "未出现">selected</#if> >未出现</option>
		            </select>
		        </th>
				<th>最新跟踪情况</th>
				<th><input type="button" style="height:25px;" value="更新日期" onclick="mdate()" /></th>
				<th><input type="button" style="height:25px;" value="登记日期" onclick="cdate()" /></th>
				<th>操作</th>
			</tr>
			<tbody id="datas">
			<#if list??>
				<#list list as list>
					<tr class="even_row">
						<td align="center" class="stress">
							<a <#if sname!="1">href="${contextPath}/index/consultant_client.htm?keyname=${list.keyname}"</#if> name="${list.keyname}" <#if list.invalid=="1">style="color:#999"</#if> title="" id="icoont173oz7">
								${list.nickname}</a></br><em class="valid" <#if list.invalid=="1">style="color:#999"</#if> ><#if list.invalid=="0">(有效)<#else>(无效)</#if></em>
						</td>
						<td align="center" style="width:50px;">${list.rawuser}</td>
						<td align="center">${list.province}<#if list.city!=''>-${list.city}</#if></td>
						<td align="center">${list.sourcens}</td>
						<td class="breakall" width="58"><div contenteditable="false" style="text-align:center;" >
						<input type="hidden" id="stat" value="<#if state??>${state}</#if>">
						<#assign states = "${list.states}">
						<#if states?contains(',')?string == true>
							<#list states?split(',') as sta>
								<p style="margin:2px 0 2px;">
								<a class="stateitem" onclick="state('${sta}')" rel="">${sta}</a>
								</p>
							</#list>
							<#elseif list.states??>
							<a class="stateitem" onclick="state('${list.states}')" rel="">${list.states}</a>
							<#else>
							无
						</#if>
						</div></td>
						<td class="breakall"><div contenteditable="false" title="${list.fallow}"><#if list.fallow?length gt 15>${list.fallow?substring(0,15)}...<#else>${list.fallow}</#if></div><em class="caption" title="${list.newTime}">${list.newTime}</em></td>
						<td align="center"><#if list.modeTime??>${list.modeTime}</#if></td>
						<td align="center"><#if list.dateTime??>${list.dateTime}</#if></td>
						<td align="center">
							<a onclick="getFollow('${list.keyname}','${list.id}')" class="btnSearchTracking">跟踪(${list.trackings})</a>
						</td>
					</tr>
	            <tr id="__TRACKING_LIST${list.id}" style="display:none">
	            	<td colspan="10" class="trackinglst" id="trackList${list.id}">
	            	</td>
	            </tr>
				</#list>
			</#if>
			</tbody>
		</table>
	</div>
	<div id="pager" style="width: 820px;">
	<ul id="pagination">
		<#if page??>
		<#if page.pagetotal?? && page.pagetotal!="0">
	<#assign pagetotal = page.pagetotal>
	<#else>
	<#assign pagetotal = 1>
	</#if>
			<#if page.currpage??>
	<#assign currpage = page.currpage>
	<#else>
	<#assign currpage = 1>
	</#if>
				<#if currpage==1 >
					<li class="previous-off">上一页</li>
					<#else>
					<li class="previous"><a href="${contextPath}/network/shic_genz.htm?currPage=${currpage-1}&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">上一页</a></li>
					</#if>
					
		<#if pagetotal<=11>
			<#list 1..pagetotal as index_up>  
	           <#if currpage==index_up > 
	           		<li class="current">${index_up}</li>
	           <#else>
	           		<li><a href="${contextPath}/network/shic_genz.htm?currPage=${index_up}&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">${index_up}</a></li>  
	           </#if>  
			</#list>  
		<#else>
			<#if currpage<=8 >
				<#list 1..9 as index_up>  
	           	<#if currpage==index_up >  
	            	<li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/network/shic_genz.htm?currPage=${index_up}&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">${index_up}</a></li> 
	           	</#if>
	           	</#list>  
	           	<li>...</li>
	           	<li><a href="${contextPath}/network/shic_genz.htm?currPage=${pagetotal}&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">${pagetotal}</a></li>  
				
			<#elseif (currpage>= 9 && currpage<pagetotal-7)  >	
				<li><a href="${contextPath}/network/shic_genz.htm?currPage=1&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">1</a></li>  
				<li>...</li>
				<#list currpage-3..currpage+3 as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/network/shic_genz.htm?currPage=${index_up}&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">${index_up}</a></li>  
	           	</#if>
	           	</#list>
				<li>...</li>
	           	<li><a href="${contextPath}/network/shic_genz.htm?currPage=${pagetotal}&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">${pagetotal}</a></li>   
			<#else>
				<li><a href="${contextPath}/network/shic_genz.htm?currPage=1&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">1</a></li> 
				<li>...</li>
				<#list pagetotal-8..pagetotal as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/network/shic_genz.htm?currPage=${index_up}&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">${index_up}</a></li> 
	           	</#if>
				</#list>  
			</#if>
			
		</#if> 
		<#if currpage==pagetotal >
		 	<li class="previous-off">下一页</li>
		<#else>
			<li class="previous"><a href="${contextPath}/network/shic_genz.htm?currPage=${currpage+1}&sname=${sname}&state_s=${state_s}&startTime=${startTime}&endTime=${endTime}&invalid=${invalid}">下一页</a></li>
		</#if>
		<li class="pageinfo">共${page.total}条记录</li>
	</#if>
	</ul>
	</div>
	<div class="emptyline"></div>
	
</body>
</html>